import axios from 'axios'
import store from '@/store/index'
import {
	Toast
} from 'vant';
import dayjs from 'dayjs'
// 创建axios实例
const service = axios.create({
	// axios中请求配置有baseURL选项，表示请求URL公共部分
	baseURL: myConfig.medicalInsuranceDecodeURL,
	method: 'post',
	// 超时
	timeout: 30000
})
// request拦截器
service.interceptors.request.use(config => {
	return config
}, error => {
	console.log(error)
	Promise.reject(error)
})

// 响应拦截器
service.interceptors.response.use(res => {
		if (res.data.code == 0) {
			res.data.success = true;
		} else {
			res.data.success = false;
			Toast({
				message: res.data.message,
			});
		}
		return res.data
	},
	error => {
		Toast({
			message: error.message || '服务出错',
		});
		return error
	}
)
export default service